# Contributor: gay <gay@disroot.org>
# Maintainer: gay <gay@disroot.org>
pkgname=stack
pkgver=2.7.5
pkgrel=0
pkgdesc="The Haskell Tool Stack"
url="https://haskellstack.org/"
arch="aarch64 x86_64" # limited by ghc
license="BSD-3-Clause"
makedepends="
	cabal
	ghc
	gmp-dev
	sqlite-dev
	zlib-dev
	"
checkdepends="ncurses-dev"
source="https://hackage.haskell.org/package/stack-$pkgver/stack-$pkgver.tar.gz
	cabal.config
	aeson.patch
	ghc9.0.x.patch
	persistent.patch
	"

export CABAL_DIR="$srcdir"/cabal

prepare() {
	default_prepare
	cp "$srcdir"/cabal.config .
	cabal update
	cabal configure --prefix=/usr
}

build() {
	cabal build --jobs=${JOBS:-1} --enable-relocatable
}

check() {
	cabal test
}

package() {
	cd dist-newstyle/build/*-linux/ghc-*/$pkgname-$pkgver/build/$pkgname
	install -Dm755 $pkgname "$pkgdir"/usr/bin/$pkgname
}

sha512sums="
fd51f990d3ccec6103c8699a8e39c970a0233a1185587a519eda659d2b45bc4496c4f261f6897c06781d0f76d2b1d526d5acdfb502fe1494f8cf048c78ba1a8d  stack-2.7.5.tar.gz
a54c0790e154105f3e96d19289a905b2b3666d61849ad69d6ed81b00a01ea30c7733ead989c02f1f782a95bcc7f0f2dff41ae1ffdd8eb0995fbbd5f54db232d7  cabal.config
818547d3d63b243daad11f2c8b811701b4b8a778196e1d69d73a4fd4829f4ad9f4134451153c80b8504f1c18fbc2ee8bca329f6c5eff9ee3c435af7a1947077d  aeson.patch
209348bd04d1cdce333e71a0570ba3781aeb36a0a5ad8a0e5f08ab9aca8f4d49f681b63cab4b7f4f1ddcc79cbf850d5cb1fc79f7a099b0bb65038774ed0a0820  ghc9.0.x.patch
73d9291ade690db1838b8dbd7b132d9e808781e5419684c04008b9e967c56d3e66eb64df8ef997d74301d92a76d4071956c5593c42841ef035c39c82ac68892d  persistent.patch
"
